/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package poker;

import prop.Carta;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.Serializable;

/**
 *
 * @author pol
 */
public class AreaDibujo extends Canvas implements Serializable {
    protected final int SIZE_X = 640, SIZE_Y = 480;

    public AreaDibujo() {
        this.setBackground(new Color(0, 128, 0));
        repaint();
    }

    public void clickRecibido(int x, int y) {
    }

    @Override
    public void paint(Graphics g) {
        //g.clearRect(0, 0, SIZE_X, SIZE_Y);
        pintaFondo(g);
    }

    protected void pintaFondo(Graphics g) {
        Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource("Fondo.png"));
        g.drawImage(img, 0, 0, this);
    }

    protected void pintaCarta(int i, int j, Carta c, Graphics g) {
        Image b = Toolkit.getDefaultToolkit().getImage(getClass().getResource("BarajaPoker.png"));
        int x = (c.getPalo() == Carta.Palos.COMODIN ? 179*c.getNum() : 179*(c.getNum() - 1));
        int y;
        if (c.getPalo() == Carta.Palos.TREBOL) y = 0*259;
        else if (c.getPalo() == Carta.Palos.DIAMANTE) y = 1*259;
        else if (c.getPalo() == Carta.Palos.CORAZON) y = 2*259;
        else if (c.getPalo() == Carta.Palos.PICA) y = 3*259;
        else y = 4*259;
        g.drawImage(b,
                    i,
                    j,
                    i + 90,
                    j + 130,
                    x,
                    y,
                    x + 179,
                    y + 259,
                    this);
    }

}
